<?php

namespace Mana\Model;

use Think\Model;

class ManagerModel extends Model
{
    protected $_validate = array(
        array('mag_name', '', '帐号名称已经存在！', 0, 'unique', 1),
        array('mag_active', array(0, 1), '状态错误!', 2, 'in', 3)
    );
    protected $_auto = array(
        array('mag_pass', 'passedit', 3, 'callback')
    );

    protected function passedit($str)
    {
        $pa = substr(md5(trim($str)), 10, 15);
        preg_match('/[0-9]+/', $str, $result);
        $ss = substr(md5(trim($result[0])), 22, 5);
        return $pa . $ss;
    }
}
